<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title> 我的宿舍卫生信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../assets/layui/css/layui.css" media="all"/>
</head>
<body style="margin: 50px">


<div class="layui-input-inline">

    <form class="layui-form" method="post" lay-filter="example">


        <div class="layui-inline">
            <div class="layui-form-item">
                <input type="checkbox" name="today" title="今日" lay-skin="primary">
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" checked=""><span>今日</span><i
                        class="layui-icon layui-icon-ok"></i></div>
            </div>
        </div>

        <div class="layui-input-inline">
            <div class="layui-form-item">
                <button type="button" class="layui-btn" id="push">提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>


</div>
<table class="layui-hide" id="test" lay-filter="users"></table>

</body>

<script type="text/javascript" src="../assets/layui/layui.js"></script>
<script type="text/javascript" src="../assets/jquery.min.js"></script>
<script type="text/javascript" src="../assets/bootstrap-3.3.7/js/bootstrap.js"></script>

<script>


    layui.use(['form', 'table', 'layer', 'laydate'], function () {
        var form = layui.form
        table = layui.table;

        $("#push").click(function () {

            showtable(form.val('example').today)
        })
        $("#reset").click(function () {
showtable()
        })
    });
    showtable()

    function showtable(istoday) {
        var table
        layui.use(['form', 'table', 'layer', 'laydate'], function () {
            var form = layui.form
            table = layui.table;

            // 获取数据
            showtable()

            function showtable() {

                table.render({
                    elem: '#test'
                    , url: '/api/v1/student/showmyhygiene'
                    , toolbar: true
                    , title: '学生卫生信息'
                    , totalRow: true
                    , cols: [[
                        {field: 'id', title: 'ID', fixed: 'left', unresize: true, sort: true}
                        , {field: 'dname', title: '宿舍号', edit: 'text', sort: true}
                        , {field: 'score', title: '分数', edit: 'number', sort: true}
                        , {field: 'pname', title: '楼宇', edit: 'text', sort: true}
                        , {field: 'time', title: '记录时间', edit: 'text', sort: true}

                    ]]
                    , page: true
                    , response: {
                        statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                    }
                    , where: {
                        "istoday": istoday,
                    }


                });
            }

        });
    }


</script>

</body>
</html>